def to_12(time: str) -> str:
    hour = time[:2]
    min = time[2:]
    if not int(hour):
        return f'12:{min} AM'
    elif int(hour) <= 12:
        return f'{int(hour)}:{min} AM'
    else:
        return f'{(int(hour) + 12)%24}:{min} PM'


if __name__ == '__main__':
    print(to_12("1124"))
    print(to_12("0030"))
    print(to_12("0900"))